package cn.com.miao.lynx.service.system.entity;

import cn.com.miao.lynx.common.base.model.TreeModel;
import lombok.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * SysPermission
 * 权限实体
 *
 * @title: SysPermission
 * @description: 权限实体
 * @author: dengmiao
 * @create: 2020-01-06 14:49
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = SysPermission.TABLE_NAME)
@SQLDelete(sql = SysPermission.LOGIC_DELETE_STATEMENT)
@Where(clause = "del_status = " + SysPermission.DELETE_FLAG_NORMAL)
public class SysPermission extends TreeModel<SysPermission, Long> {

    public final static String TABLE_NAME = "sys_permission";

    public final static String LOGIC_DELETE_STATEMENT = "update " + TABLE_NAME + " set del_status = " + SysDict.DELETE_FLAG_DELETE + " where id = ?";

    /**
     * name|key
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT 'name|key'")
    private String name;

    /**
     * 菜单名称
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '菜单名称'")
    private String title;

    /**
     * 菜单权限编码，例如：“sys:schedule:list,sys:schedule:info”,多个逗号隔开
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '菜单权限编码，例如：“sys:schedule:list,sys:schedule:info”,多个逗号隔开'")
    private String perms;

    /**
     * 菜单图标
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '菜单图标'")
    private String icon;

    /**
     * 组件
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '组件'")
    private String component;

    /**
     * 路径
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '路径'")
    private String path;
    /**
     * 一级菜单跳转地址
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '一级菜单跳转地址'")
    private String redirect;

    /**
     * 菜单排序
     */
    @Column(columnDefinition = "int(11) DEFAULT NULL COMMENT '菜单排序'")
    private Integer sortNo;

    /**
     * 类型（0：一级菜单；1：子菜单 ；2：按钮权限）
     */
    @Column(columnDefinition = "int(1) DEFAULT NULL COMMENT '类型（0：一级菜单；1：子菜单 ；2：按钮权限）'")
    private Integer menuType;

    /**
     * 是否叶子节点: 1:是 0:不是
     */
    @Column(columnDefinition = "int(1) DEFAULT NULL COMMENT '是否叶子节点: 1:是 0:不是'")
    private Integer isLeaf;

    /**
     * 描述
     */
    @Column(columnDefinition = "varchar(255) DEFAULT NULL COMMENT '描述'")
    private String description;

    /**
     * 是否隐藏路由菜单: 0否,1是（默认值0）
     */
    @Column(nullable = false, columnDefinition = "int(1) DEFAULT 0 COMMENT '是否隐藏路由菜单: 0否,1是（默认值0）'")
    private boolean hidden;

    /**
     * alwaysShow
     */
    @Column(nullable = false, columnDefinition = "int(1) DEFAULT 0 COMMENT 'alwaysShow'")
    private boolean alwaysShow;

    /**
     * 外部跳转标识(_target)
     */
    @Column(columnDefinition = "varchar(10) DEFAULT '' COMMENT 'target'")
    private String target;

    /**
     * 强制菜单显示为Item而不是SubItem
     */
    @Column(columnDefinition = "int(1) DEFAULT 0 COMMENT '隐藏子菜单'")
    private boolean hideChildren;
}
